<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <title>去保养-有人情味的保养</title>
    <meta name="keywords" content="去保养,汽车保养,汽车配件,汽车维修,养车,4S店品质,氦修驿站" />
    <meta name="description" content="上门取车保养、保养在线观看、咖啡馆里做保养、夜间保养" />
    <link rel="stylesheet" type="text/css" href="{:C('WEB_URL')}Public/css/base.css">
    <link rel="stylesheet" type="text/css" href="{:C('WEB_URL')}Public/mobile/css/master.css">
<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "//hm.baidu.com/hm.js?11ad56ca0738ac14d150a362fca3e058";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>


</head>
<body>
    <header class="tcenter fs14">
        <a href="tel:4006730088" class="tel iconfont">&#xe610;</a>
        <a href="{:C('WEB_URL')}mobile/" class="iconfont fright">&#xe60f;</a>
        <a href="javascript:window.history.go(-1)" class="iconfont fleft">&#xe612;</a>
        选择车型
    </header>
    
    <div class="step">
        <eq name="_SESSION['location']" value="3301">
            <ul class="hz">
                <li class="over"><span>1</span>选择车型</li>
                <li class="current"><span>2</span>填写信息</li>
                <li><span>3</span>订单完成</li>
            </ul>
        <else />
            <ul>
                <li class="over"><span>1</span>选择车型</li>
                <li class="current"><span>2</span>填写信息</li>
                <li><span>3</span>选择店铺</li>
                <li><span>4</span>订单完成</li>
            </ul>
        </eq>
    </div>
    <div class="carInfo" style="background:#f5f5f5">
        <p>{$auto['brand_name']} {$auto['model_name']} {$auto['model_pl']} {$auto['model_year']}  <a href="{:U('step1')}?choose=true&back=home">更换 &gt;</a></p>
        <span id="J_valueJY" class="hide">{$auto['capacity']}</span>
    </div>
    <style>

        
        .goodsList{ position:relative;padding:15px;margin-top:30px;}

        .goodsList h3 i{border:2px solid #fff; position:absolute;top:-20px;left:10px;background:#0093D0;width:32px;height:32px;border-radius: 20px;color:#fff;text-align:center;line-height:32px;}
        .goodsList h3{font-size:16px;padding-left:40px;margin-top:-20px;padding-bottom:10px;}
        .goodsList li{border-bottom:1px dashed #ddd;padding:5px 0;}
        .goodsList li img{margin-left:0px;}
    </style>
    <form action="{:U('step3')}" method="get" id="J_myForm">
        <div class="goodsList">
            <h3><i>&#xe623;</i>您的配件</h3>

            <ul class="clearfix">
                <li>
                    <img src="http://app2.haixiuyizhan.com/{$jyF['logo']}" alt="">
                    <p class="name">{$jyF['pj_name']}&nbsp;{$jyF['weight']}L*{$jyF['count']}</p>
                    <p class="price">￥{$jyF['pj_csprice']*$jyF['count']}<span>￥{$jyF['pj_scprice']*$jyF['count']}</span></p>
                </li>
                <li>
                    <img src="http://app2.haixiuyizhan.com/{$jv['logo']}" alt="">
                    <p class="name">{$jv['pj_pinpai']}&nbsp;{$jv['pj_xinghao']}</p>
                    <p class="price">￥{$jv['pj_csprice']}<span>￥{$jv['pj_scprice']}</span></p>
                </li>
                <notempty name="jyO">
                    <li>
                        <img src="http://app2.haixiuyizhan.com/{$jyO['logo']}" alt="">
                        <p class="name">{$jyO['pj_name']}&nbsp;{$jyO['weight']}L*{$jyO['count']}</p>
                        <p class="price">￥{$jyO['pj_csprice']*$jyO['count']}<span>￥{$jyO['pj_scprice']*$jyO['count']}</span></p>
                    </li>
                </notempty>

            </ul>
        </div>
        <p class="line pt10">&nbsp;</p>
        <div class="userData">
            <h3><i>&#xe614;</i>您的收货地址</h3>
            <ul>
                <li><input type="text" name="realname" value="{$_SESSION['user']['realname']}" placeholder="您的姓名"></li>
                <li><input type="tel" name="phone" value="{$_SESSION['user']['username']}"  placeholder="您的手机号"></li>
                <li><input type="text" name="address" value="{$_SESSION['user']['address']}" placeholder="您的收货地址"></li>
            </ul>
        </div>
        <p class="line pt10">&nbsp;</p>
        <div class="couponList userData">
            <h3><i>&#xe616;</i>优惠券</h3>
            <ul id="J_couponList">
               <?php foreach($couponList as $list){ if($list['status']==1){ ?>
                <li onclick="chooseGoods.chooseCoupon(this)" data-type="{$list['type']}" data-val="<?php if($list['type']==4){ echo $youhui;}else{echo $list['money'];} ?>" data-low="{$list['low_money']}" id="J_coupon{$list['code']}">
                    <i>&#xe60a;</i>
                    <em><?php if($list['type'] == 1){echo '-￥'.$list['money'];}elseif($list['type'] == 2){echo $list['money'].'折';}elseif($list['type']==4){ echo "-￥".$youhui;} ?></em>
                    <p class="name"><span><?php echo $list['content']; ?></span></p>
                </li>
                <?php }} ?>
            </ul>
            <div class="addCoupon">
                <input type="text" id="J_couponCode" /><a href="javascript:void(0)" id="J_useCoupon">添加优惠券</a>
            </div>
        </div>
        <p class="line"></p>

        <eq name="already" value="2">
        <div class="mian userData">
            <h3><i>得</i>免单券</h3>
            <ul>
                <li >
                    <p class="name" style="font-size:13px;"><ins id="J_getPrice"></ins>免单券<span class="ml10">(先支付，后返券)</span><br /><span>买多少返多少，最高可返1000元</span></p>
                </li>
            </ul>
        </div>
        <p class="line"></p>
        </eq>
        <div class="totalMain" class="tright">
            <p class="totalPrice">总价：{$_SESSION['order']['totalPrice']}</p>
            <p class="couponPrice">优惠：￥0</p>
        </div>
        <p style="height:55px;background:#F4F4F4"></p>

            <div class="pay">
                <p class="needPay" <neq name="already" value="2">style="bottom:8px;"</neq> ><span>需支付：</span><em id="J_payPrice">￥{$_SESSION['order']['totalPrice']}</em></p>
                <p class="couponTxt"></p>
                <a href="javascript:void(0)" id="J_btnGoPay">立即支付</a>
            </div>
        
    </form>
    
    <div id="loading">
        <p>努力加载中...</p>
    </div>

    <input type="hidden" id="J_already" value="{$already}" />
    <input type="hidden" id="J_total" value="{$_SESSION['order']['totalPrice']}" />
    <input type="hidden" id="J_priceJY" value="{$_SESSION['order']['priceJY']}" />

    <include file="Public/mobileHome" />
    <script type="text/javascript" src="{:C('WEB_URL')}Public/mobile/js/chooseGoods.js"></script>
    <script>
        chooseGoods.couponStatus="{$already['status']}";
        chooseGoods.couponMoney="{$already['rand_money']}";
        chooseGoods.init();

    	var server = "{$Server}";
        $(function(){
            $("#J_btnGoPay").on("click",function(){

                var coupon=$("#J_couponList").find(".current"),
                    userDom=$(".userData"),
                    _t=$(this),
                    data={};

                if(typeof coupon[0]!="undefined"){
                    data['coupon']=coupon.attr("id").replace(/\D/g,"");
                }
                
                data['phone']=userDom.find("input[name='phone']").val();
                data['realname']=userDom.find("input[name='realname']").val();
                data['address']=userDom.find("input[name='address']").val();
                data['wx_id']=$("#J_wx_id").val();
                data['source']=4;

                if(data['realname']==""){
                    showMsgTip("请输入您的姓名");
                    return false;
                }else if(!/^(13|15|18|14|17)[0-9]{9}$/.test(data['phone'])){
                    showMsgTip("请输入正确的手机号");
                    return false;
                }else if(data['address']==""){
                    showMsgTip("请输入您的收货地址");
                    return false;
                }

                $("#loading").show();
                $.ajax({
                    type:"post",
                    url:"{:C('WEB_URL')}mobile/createOrder",
                    data:data,
                    dataType:"json",
                    success:function(res){
                        if(server == 'wx'){
                    		callpay(res);
                    	}else{
                    		window.location.href="{:U('alipaywap')}?order_id="+res;
                    	}
                    }
                })

            })

            $("#J_useCoupon").on("click",function(){
                var code=$("#J_couponCode").val();
                if(!/\d{16}/.test(code)){
                    showMsgTip("请输入正确的优惠码",2000);
                    return false;
                }

                if(typeof $("#J_coupon"+code)[0]!="undefined"){
                    showMsgTip("该优惠券已添加",2000);
                    return false;
                }

                $.ajax({
                    url:"{:C('WEB_URL')}mobile/valCoupon/",
                    type:"post",
                    data:{"code":code},
                    dataType:"json",
                    success:function(res){
                        if(res.status==1){
                            printCoupon(res.data);
                        }else{
                            showMsgTip(res.info,2000);
                            return false;
                        }
                    }
                })
            })
        })

        
        function printCoupon(data){
            var html='<li onclick="chooseGoods.chooseCoupon(this)" data-type="'+data['type']+'" data-val="'+data['money']+'" data-low="'+data['low_money']+'">'+
                        '<i>&#xe60a;</i>'+
                        '<em>-￥'+data['money']+'</em>'+
                        '<p class="name"><span>'+data['content']+'</span></p>'+
                    '</li>';

                $("#J_couponList").append(html);

            $("#J_couponList").find("li:last").click();
            $("#J_couponCode").val("");
        }

        //调用微信JS api 支付
        function jsApiCall(jsApiParameters){
            
            WeixinJSBridge.invoke(
                'getBrandWCPayRequest',
                jsApiParameters,
                function(res){
                    WeixinJSBridge.log(res.err_msg);
                    if(res.err_msg=="get_brand_wcpay_request:ok"){
                        window.location.href="{:U('step3')}";
                    }else{

                        //window.location.href="{:U('myOrder')}";
                    }
                }
            );
        }

        function callpay(jsApiParameters){

            if (typeof WeixinJSBridge == "undefined"){
                if( document.addEventListener ){
                    document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
                }else if (document.attachEvent){
                    document.attachEvent('WeixinJSBridgeReady', jsApiCall); 
                    document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
                }
            }else{
                $("#loading").hide();
                jsApiCall(jsApiParameters);
            }
        }
    </script>
</body>
</html>